package edu.lhh.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import edu.lhh.model.scoretype;

public class scoretypedao {
	
	public void add(scoretype type){
		
		String sql = "INSERT INTO score(indexs,id,math,english,pe) VALUE('"+type.getIndex()+"','"+type.getId()+"','"+type.getMath()+"','"+type.getEnglish()+"','"+type.getPe()+"')";
		DbUtils.execute(sql);
	}
	
	public scoretype findbyid(String id) throws SQLException{
		scoretype tp = new scoretype();
		String sql = "SELECT * FROM score WHERE id = '"+id+"'";
		ResultSet rs = DbUtils.query(sql);
		if (rs.next()){
			tp.setId(rs.getString("id"));
			tp.setIndex(rs.getInt("indexs"));
			tp.setMath(rs.getInt("math"));
			tp.setEnglish(rs.getInt("english"));
			tp.setPe(rs.getInt("pe"));
		}
		return tp;
	}
	public void updata(scoretype tp ){
		String sql ="UPDATE score SET indexs = '"+tp.getIndex()+"',math = '"+tp.getMath()+"',english = '"+tp.getEnglish()+"',pe = '"+tp.getPe()+"' WHERE id = '"+tp.getId()+"'";
		DbUtils.execute(sql);
		
		
	}

}
